package com.example.blogsystem.mapper;

import com.example.blogsystem.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserInfoMapper {
    /**
     * 根据用户名查询密码是否正确
     */
    @Select("select * from user where user_name = #{userName}")
    UserInfo queryByUserName(String userName);
    /**
     * 根据用户id查询用户信息
     */
    @Select("select * from user where id = #{userId}")
    UserInfo queryByUserId(Integer userId);

    /**
     * 注册用户
     */
    @Insert("insert into user(user_name,password,github_url) values(#{userName},#{password},#{githubUrl})")
    Integer registerUser(UserInfo userInfo);

    /**
     * 统计用户总数
     */
    @Select("select count(id) from user")
    Integer countUser();
}
